package com.householditemtwo.index.dao;

import java.sql.SQLException;
import java.util.ArrayList;
import java.util.List;

import com.householditemtwo.common.entity.Carousel;
import com.householditemtwo.common.entity.Compary;
import com.householditemtwo.common.entity.Designer;
import com.householditemtwo.common.entity.News;
import com.householditemtwo.common.entity.Product;
import com.householditemtwo.common.entity.Produtimg;
import com.householditemtwo.common.utils.DBManager;
import com.householditemtwo.common.utils.QueryDataResult;

public class AboutDao {
	/**
	 * 查询公司信息
	 * @return
	 */
	public List<Compary> selectCompary() {
		DBManager db=new DBManager();
		String sql="select * from compary ";
		QueryDataResult qdr=db.executeQuery(sql);
		Carousel emp=new Carousel();
		ArrayList<Compary> list=new ArrayList<Compary>();
		try {
			while(qdr.rs.next()) {
				Compary c=new Compary();
				c.setCpyid(qdr.rs.getInt(1));
				c.setCpyname(qdr.rs.getString(2));
				c.setCpylogo(qdr.rs.getString(3));
				c.setCpyculture(qdr.rs.getString(4));
				c.setCpysimintro(qdr.rs.getString(5));
				c.setCpydeiIntro(qdr.rs.getString(6));
				c.setCpyaddress(qdr.rs.getString(7));
				c.setCpyphone(qdr.rs.getString(8));
				c.setCpyemail(qdr.rs.getString(9));
				list.add(c);
			}
		}catch(SQLException e) {
			e.printStackTrace();
		}
		
		//返回查询的结果
		return list;
		
	}
	/**
	 * 查询设计师表
	 * @return
	 */
	
	public List<Designer> selectDesigner() {
		DBManager db=new DBManager();
		String sql="select * from designer order by desid desc ";
		QueryDataResult qdr=db.executeQuery(sql);
		Carousel emp=new Carousel();
		ArrayList<Designer> list=new ArrayList<Designer>();
		try {
			while(qdr.rs.next()) {
				Designer c=new Designer();
				c.setDesid(qdr.rs.getInt(1));
				c.setDesname(qdr.rs.getString(2));
				c.setDesgrade(qdr.rs.getString(3));
				c.setDespisture(qdr.rs.getString(4));
				list.add(c);
			}
		}catch(SQLException e) {
			e.printStackTrace();
		}
		
		//返回查询的结果
		return list;
		
	}
	
	/**
	 * 查询所有轮播图
	 * @return
	 */
		
	public List<Carousel> selectAllCarousel() {
		DBManager db=new DBManager();
		String sql="select * from carousel order by crWeight desc";
		QueryDataResult qdr=db.executeQuery(sql);
		Carousel emp=new Carousel();
		ArrayList<Carousel> list=new ArrayList<Carousel>();
		try {
			while(qdr.rs.next()) {
				Carousel c=new Carousel();
				c.setCrimgid(qdr.rs.getInt(1));
				c.setCrurl(qdr.rs.getString(2));
				c.setProid(qdr.rs.getInt(3));
				c.setCrweight(qdr.rs.getInt(4));
				list.add(c);
			}
		}catch(SQLException e) {
			e.printStackTrace();
		}
		
		//返回查询的结果
		return list;
	}
	
	
	
	
	
}
